﻿using Cysharp.Threading.Tasks;
using UnityEngine;
using YooAsset;

namespace Client.Base
{
    public class FsmClearUnUsedAssets : PatchState
    {
        public override async void OnEnter()
        {
            this.Log("[Patch] FsmClearUnUsedAssets.");
            foreach (var name in AppInfo.Packages)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    var package = YooAssets.GetPackage(name);
                    var operation = package.ClearCacheFilesAsync(EFileClearMode.ClearUnusedBundleFiles);
                    await operation.ToUniTask();
                }
            }
            PatchHandle.Instance.Change<FsmStartGame>();
        }
    }

}

